package com.atguigu.ssyx.acl.service.impl;

import com.atguigu.ssyx.acl.mapper.AdminMapper;
import com.atguigu.ssyx.acl.service.AdminService;
import com.atguigu.ssyx.model.acl.Admin;
import com.atguigu.ssyx.vo.acl.AdminQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Description:
 * @Author: Ian
 * @Date: 2024/3/13 19:33
 */
@Service
@Slf4j
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    /**
     * 分页条件查询用户
     * @param page
     * @param adminQueryVo
     * @return
     */
    @Override
    public IPage queryPageAdmin(Page page, AdminQueryVo adminQueryVo) {
        // 封装条件查询
        QueryWrapper queryWrapper = new QueryWrapper();

        if (!StringUtils.isEmpty(adminQueryVo.getUsername())){
            queryWrapper.like("username",adminQueryVo.getUsername());
        }
        IPage<Admin> page1 = baseMapper.selectPage(page, queryWrapper);

        log.info(page1.getTotal() + "");
        return page1;
    }

}
